﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HRM.BLL;
using HRM.DAL.DAO;
using HRM.DAL.Report;

namespace HRM.UI.HRAdminUI
{
    public partial class AdminMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["Code"] != null && (int)Session["Role"] == 3)
                {
                    // welcome 
                }
                else
                {
                    Response.Redirect("~/Index.aspx");
                }
                LoadCompanyInfo();
                GetEmployeeInfo();
            }
        }

        private void LoadCompanyInfo()
        {
            Company company = new Company();
            company = company.GetCompanyInfo();
            txtCompanyName.InnerText = company.Name;
            txtAddress.InnerText = company.Address;
        }

        private void GetEmployeeInfo()
        {
            Code code = new Code();
            code.CodeName = Session["Code"].ToString();
            EmployeeManager manager = new EmployeeManager();
            ViewEmployee viewEmployee = new ViewEmployee();
            viewEmployee = manager.SearchEmployeeByCode(code);
            Session["name"] = viewEmployee.Employee.Name;
            userNameLbl.Text = "Welcome " + viewEmployee.Employee.Name;
            //empImage.ImageUrl = viewEmployee.Photo.FileName;
            userDesignation.Text = " - " + viewEmployee.Designation.Title;
            joinDate.Text = (viewEmployee.Employee.JoiningDate).ToShortDateString();
            empCode.Text = code.CodeName;
        }
    }
}